package su.mvc.model;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Parent;

import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.List;

@Entity
public class MenuItem {

    @Id
    private Long id;
    
    private Key key;
    
    private String name;

    private Integer order = 1000;
    
    private String urlString;

    private String redirectUrl;

    private Boolean hidden = false;
    
    @Transient
    private String content;

    private Long contentId;

    @Parent
    private Key<MenuItem> parentItemKey;

    @Transient
    private List<MenuItem> childItems = new ArrayList<MenuItem>();


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Key<MenuItem> getParentItemKey() {
        return parentItemKey;
    }

    public void setParentItemKey(Key<MenuItem> parentItemKey) {
        this.parentItemKey = parentItemKey;
    }

    public List<MenuItem> getChildItems() {
        return childItems;
    }

    public void setChildItems(List<MenuItem> childItems) {
        this.childItems = childItems;
    }
    
    public void addChildItem(MenuItem menuItem){
        childItems.add(menuItem);
    }

    public void deleteChildItem(MenuItem menuItem){
        childItems.remove(menuItem);
    }

    public Key getKey() {
        return key;
    }

    public void setKey(Key key) {
        this.key = key;
    }

    public String getUrlString() {
        return urlString;
    }

    public void setUrlString(String urlString) {
        this.urlString = urlString;
    }

    public String getRedirectUrl() {
        return redirectUrl;
    }

    public void setRedirectUrl(String redirectUrl) {
        this.redirectUrl = redirectUrl;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Long getContentId() {
        return contentId;
    }

    public void setContentId(Long contentId) {
        this.contentId = contentId;
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    public Boolean getHidden() {
        return hidden;
    }

    public void setHidden(Boolean hidden) {
        this.hidden = hidden;
    }
}
